# coding=utf-8
"""
Author: Mr.夏末
@Function: 深拷贝与浅拷贝
"""
# 拷贝指针：浅拷贝:指向的内存地址一样
a = [1, 2, 3, 4, 5]
# 拷贝指针a
b = a
print(a, b)

a[0] = 66
print(a, b)
print(id(a))
print(id(b))

print("------------------------------------------------")

# 类类型:基本都是深拷贝
a = [1, 2, 3, 4]
b = [1, 2, 3, 4]
print(id(a))
print(id(b))

# 拷贝内存里面的值：深拷贝：指向的内存地址不一样
a = [1, 2, 3, 4]
b = a[0:]
a[0] = 66
print(a, b)

b = a.copy()
a[0] = 77
print(a, b)
print(id(a))
print(id(b))

print("------------------------------------------------")
# 字典浅拷贝
d1 = {1: 2, 3: 4, 5: 6}
d2 = d1
print(id(d1))
print(id(d2))
# 字典深拷贝
d2 = d1.copy()
print(id(d1))
print(id(d2))
# 字典深拷贝
d2 = {}
d2.update(d1)
print(id(d1))
print(id(d2))